import {message} from "./message";

let img = {
    type: ['image/png','image/jpg','image/jpeg'],
    size: 10485760,
};

/**
 * 验证上传图片
 * @param file 上传的图片
 */
export function validUploadImg(file){
    let size = file.size;
    let type = file.type;
    if(img.type.indexOf(type) == -1){
        message.warning("上传图片类型只能是" + img.type);
        return false;
    }
    if(size > img.size){
        message.warning("上传图片大小不能超过" + img.size / 1024 / 1024 + "M");
        return false;
    }
    return true;
}